name = 'lili'
age = 10
{} 里面 0 指的format 中第一个传值
print('my name is {1} ,age is {0}.'.format(name,age)) #结果：my name is 10 ,age is lili.
print('my name is {0} ,age is {1},{0}{1}'.format(name,age)) #结果 my name is lili ,age is 10,lili10


format也支持列表及字典
namelist = ['hha','zs','ls','jc']
print('we name are {} {} {}'.format(*namelist))

dictlist = {'sex':'female','favorite':'math'}
print('爱好是{} 名字是{}'.format(dictlist.keys(),dictlist.values()))
#上面的结果是爱好是dict_keys(['sex', 'favorite']) 名字是dict_values(['female', 'math'])
print('爱好是{} 名字是{}'.format(*dictlist)) #结果：爱好是sex 名字是favorite


class_name = 'math'
student = 'lisi'
print(f"student {student} like {class_name}") #结果 student lisi like math
list1=['female','cose']
print(f"list {list1[0]} {list1[1]}") #结果：list female cose
dictlist = {'hah':'##','set1':'111'}
print(f"dictname {dictlist['hah']} {dictlist['set1']}")  #结果：dictname ## 111


print(f"lambda 函数操作{(lambda x : x+5)(2) }")  #存在冒号 所以加了括号
#结果：lambda 函数操作7